#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL T,n,m,L,V,d[100000],v[100000],a[100000],p[100000],h[100000];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&T);
    while(T--){
        scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
        LL ans=0;
        for(LL i=0;i<n;i++) scanf("%lld%lld%lld",&d[i],&v[i],&a[i]);
        for(LL i=0;i<m;i++) scanf("%lld",&p[i]);
        for(LL i=0;i<n;i++) if(d[i]<=p[m-1]) if(v[i]*v[i]+2*a[i]*(p[m-1]-d[i])>V*V) ans++;
        printf("%lld %lld\n",ans,m-(ans!=0));
    }
    return 0;
}
